/**
 */
package org.mro.grib.model.files.secondEdition.sections.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.mro.grib.core.GridException;
import org.mro.grib.core.SectionException;
import org.mro.grib.model.files.secondEdition.grids.GridDefinitionTemplateNumber;
import org.mro.grib.model.files.secondEdition.grids.IGridDefinition;
import org.mro.grib.model.files.secondEdition.sections.GridDefinitionSection;
import org.mro.grib.model.files.secondEdition.sections.SectionsPackage;
import org.mro.grib.util.GribSecondEditionTemplatesFactory;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Grid Definition Section</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getStartOffset <em>Start Offset</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getEndOffset <em>End Offset</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getLength <em>Length</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getSourceOfGridDefinition <em>Source Of Grid Definition</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getNumberOfDataPoints <em>Number Of Data Points</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getNumberOfOctetsForOptionalListOfNumbers <em>Number Of Octets For Optional List Of Numbers</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getInterpretationOfListOfNumbers <em>Interpretation Of List Of Numbers</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getGridDefinitionTemplateNumber <em>Grid Definition Template Number</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.sections.impl.GridDefinitionSectionImpl#getGridDefinitionTemplate <em>Grid Definition Template</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GridDefinitionSectionImpl extends EObjectImpl implements GridDefinitionSection {
	/**
	 * The default value of the '{@link #getStartOffset() <em>Start Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartOffset()
	 * @generated
	 * @ordered
	 */
	protected static final long START_OFFSET_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getStartOffset() <em>Start Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartOffset()
	 * @generated
	 * @ordered
	 */
	protected long startOffset = START_OFFSET_EDEFAULT;

	/**
	 * The default value of the '{@link #getEndOffset() <em>End Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEndOffset()
	 * @generated
	 * @ordered
	 */
	protected static final long END_OFFSET_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getEndOffset() <em>End Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEndOffset()
	 * @generated
	 * @ordered
	 */
	protected long endOffset = END_OFFSET_EDEFAULT;

	/**
	 * The default value of the '{@link #getLength() <em>Length</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLength()
	 * @generated
	 * @ordered
	 */
	protected static final int LENGTH_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getLength() <em>Length</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLength()
	 * @generated
	 * @ordered
	 */
	protected int length = LENGTH_EDEFAULT;

	/**
	 * The default value of the '{@link #getSourceOfGridDefinition() <em>Source Of Grid Definition</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSourceOfGridDefinition()
	 * @generated
	 * @ordered
	 */
	protected static final byte SOURCE_OF_GRID_DEFINITION_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getSourceOfGridDefinition() <em>Source Of Grid Definition</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSourceOfGridDefinition()
	 * @generated
	 * @ordered
	 */
	protected byte sourceOfGridDefinition = SOURCE_OF_GRID_DEFINITION_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfDataPoints() <em>Number Of Data Points</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfDataPoints()
	 * @generated
	 * @ordered
	 */
	protected static final int NUMBER_OF_DATA_POINTS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getNumberOfDataPoints() <em>Number Of Data Points</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfDataPoints()
	 * @generated
	 * @ordered
	 */
	protected int numberOfDataPoints = NUMBER_OF_DATA_POINTS_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfOctetsForOptionalListOfNumbers() <em>Number Of Octets For Optional List Of Numbers</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfOctetsForOptionalListOfNumbers()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfOctetsForOptionalListOfNumbers() <em>Number Of Octets For Optional List Of Numbers</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfOctetsForOptionalListOfNumbers()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfOctetsForOptionalListOfNumbers = NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS_EDEFAULT;

	/**
	 * The default value of the '{@link #getInterpretationOfListOfNumbers() <em>Interpretation Of List Of Numbers</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInterpretationOfListOfNumbers()
	 * @generated
	 * @ordered
	 */
	protected static final byte INTERPRETATION_OF_LIST_OF_NUMBERS_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getInterpretationOfListOfNumbers() <em>Interpretation Of List Of Numbers</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInterpretationOfListOfNumbers()
	 * @generated
	 * @ordered
	 */
	protected byte interpretationOfListOfNumbers = INTERPRETATION_OF_LIST_OF_NUMBERS_EDEFAULT;

	/**
	 * The default value of the '{@link #getGridDefinitionTemplateNumber() <em>Grid Definition Template Number</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGridDefinitionTemplateNumber()
	 * @generated
	 * @ordered
	 */
	protected static final short GRID_DEFINITION_TEMPLATE_NUMBER_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getGridDefinitionTemplateNumber() <em>Grid Definition Template Number</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGridDefinitionTemplateNumber()
	 * @generated
	 * @ordered
	 */
	protected short gridDefinitionTemplateNumber = GRID_DEFINITION_TEMPLATE_NUMBER_EDEFAULT;

	/**
	 * The cached value of the '{@link #getGridDefinitionTemplate() <em>Grid Definition Template</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGridDefinitionTemplate()
	 * @generated
	 * @ordered
	 */
	protected IGridDefinition gridDefinitionTemplate;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GridDefinitionSectionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SectionsPackage.Literals.GRID_DEFINITION_SECTION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getStartOffset() {
		return startOffset;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStartOffset(long newStartOffset) {
		long oldStartOffset = startOffset;
		startOffset = newStartOffset;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__START_OFFSET, oldStartOffset, startOffset));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getEndOffset() {
		return endOffset;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEndOffset(long newEndOffset) {
		long oldEndOffset = endOffset;
		endOffset = newEndOffset;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__END_OFFSET, oldEndOffset, endOffset));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getLength() {
		return length;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLength(int newLength) {
		int oldLength = length;
		length = newLength;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__LENGTH, oldLength, length));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getSourceOfGridDefinition() {
		return sourceOfGridDefinition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSourceOfGridDefinition(byte newSourceOfGridDefinition) {
		byte oldSourceOfGridDefinition = sourceOfGridDefinition;
		sourceOfGridDefinition = newSourceOfGridDefinition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__SOURCE_OF_GRID_DEFINITION, oldSourceOfGridDefinition, sourceOfGridDefinition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getNumberOfDataPoints() {
		return numberOfDataPoints;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfDataPoints(int newNumberOfDataPoints) {
		int oldNumberOfDataPoints = numberOfDataPoints;
		numberOfDataPoints = newNumberOfDataPoints;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_DATA_POINTS, oldNumberOfDataPoints, numberOfDataPoints));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfOctetsForOptionalListOfNumbers() {
		return numberOfOctetsForOptionalListOfNumbers;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfOctetsForOptionalListOfNumbers(byte newNumberOfOctetsForOptionalListOfNumbers) {
		byte oldNumberOfOctetsForOptionalListOfNumbers = numberOfOctetsForOptionalListOfNumbers;
		numberOfOctetsForOptionalListOfNumbers = newNumberOfOctetsForOptionalListOfNumbers;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS, oldNumberOfOctetsForOptionalListOfNumbers, numberOfOctetsForOptionalListOfNumbers));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getInterpretationOfListOfNumbers() {
		return interpretationOfListOfNumbers;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInterpretationOfListOfNumbers(byte newInterpretationOfListOfNumbers) {
		byte oldInterpretationOfListOfNumbers = interpretationOfListOfNumbers;
		interpretationOfListOfNumbers = newInterpretationOfListOfNumbers;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__INTERPRETATION_OF_LIST_OF_NUMBERS, oldInterpretationOfListOfNumbers, interpretationOfListOfNumbers));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getGridDefinitionTemplateNumber() {
		return gridDefinitionTemplateNumber;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGridDefinitionTemplateNumber(short newGridDefinitionTemplateNumber) {
		short oldGridDefinitionTemplateNumber = gridDefinitionTemplateNumber;
		gridDefinitionTemplateNumber = newGridDefinitionTemplateNumber;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE_NUMBER, oldGridDefinitionTemplateNumber, gridDefinitionTemplateNumber));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IGridDefinition getGridDefinitionTemplate() {
		return gridDefinitionTemplate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetGridDefinitionTemplate(IGridDefinition newGridDefinitionTemplate, NotificationChain msgs) {
		IGridDefinition oldGridDefinitionTemplate = gridDefinitionTemplate;
		gridDefinitionTemplate = newGridDefinitionTemplate;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE, oldGridDefinitionTemplate, newGridDefinitionTemplate);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGridDefinitionTemplate(IGridDefinition newGridDefinitionTemplate) {
		if (newGridDefinitionTemplate != gridDefinitionTemplate) {
			NotificationChain msgs = null;
			if (gridDefinitionTemplate != null)
				msgs = ((InternalEObject)gridDefinitionTemplate).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE, null, msgs);
			if (newGridDefinitionTemplate != null)
				msgs = ((InternalEObject)newGridDefinitionTemplate).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE, null, msgs);
			msgs = basicSetGridDefinitionTemplate(newGridDefinitionTemplate, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE, newGridDefinitionTemplate, newGridDefinitionTemplate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE:
				return basicSetGridDefinitionTemplate(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SectionsPackage.GRID_DEFINITION_SECTION__START_OFFSET:
				return getStartOffset();
			case SectionsPackage.GRID_DEFINITION_SECTION__END_OFFSET:
				return getEndOffset();
			case SectionsPackage.GRID_DEFINITION_SECTION__LENGTH:
				return getLength();
			case SectionsPackage.GRID_DEFINITION_SECTION__SOURCE_OF_GRID_DEFINITION:
				return getSourceOfGridDefinition();
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_DATA_POINTS:
				return getNumberOfDataPoints();
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS:
				return getNumberOfOctetsForOptionalListOfNumbers();
			case SectionsPackage.GRID_DEFINITION_SECTION__INTERPRETATION_OF_LIST_OF_NUMBERS:
				return getInterpretationOfListOfNumbers();
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE_NUMBER:
				return getGridDefinitionTemplateNumber();
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE:
				return getGridDefinitionTemplate();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SectionsPackage.GRID_DEFINITION_SECTION__START_OFFSET:
				setStartOffset((Long)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__END_OFFSET:
				setEndOffset((Long)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__LENGTH:
				setLength((Integer)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__SOURCE_OF_GRID_DEFINITION:
				setSourceOfGridDefinition((Byte)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_DATA_POINTS:
				setNumberOfDataPoints((Integer)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS:
				setNumberOfOctetsForOptionalListOfNumbers((Byte)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__INTERPRETATION_OF_LIST_OF_NUMBERS:
				setInterpretationOfListOfNumbers((Byte)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE_NUMBER:
				setGridDefinitionTemplateNumber((Short)newValue);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE:
				setGridDefinitionTemplate((IGridDefinition)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SectionsPackage.GRID_DEFINITION_SECTION__START_OFFSET:
				setStartOffset(START_OFFSET_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__END_OFFSET:
				setEndOffset(END_OFFSET_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__LENGTH:
				setLength(LENGTH_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__SOURCE_OF_GRID_DEFINITION:
				setSourceOfGridDefinition(SOURCE_OF_GRID_DEFINITION_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_DATA_POINTS:
				setNumberOfDataPoints(NUMBER_OF_DATA_POINTS_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS:
				setNumberOfOctetsForOptionalListOfNumbers(NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__INTERPRETATION_OF_LIST_OF_NUMBERS:
				setInterpretationOfListOfNumbers(INTERPRETATION_OF_LIST_OF_NUMBERS_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE_NUMBER:
				setGridDefinitionTemplateNumber(GRID_DEFINITION_TEMPLATE_NUMBER_EDEFAULT);
				return;
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE:
				setGridDefinitionTemplate((IGridDefinition)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SectionsPackage.GRID_DEFINITION_SECTION__START_OFFSET:
				return startOffset != START_OFFSET_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__END_OFFSET:
				return endOffset != END_OFFSET_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__LENGTH:
				return length != LENGTH_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__SOURCE_OF_GRID_DEFINITION:
				return sourceOfGridDefinition != SOURCE_OF_GRID_DEFINITION_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_DATA_POINTS:
				return numberOfDataPoints != NUMBER_OF_DATA_POINTS_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS:
				return numberOfOctetsForOptionalListOfNumbers != NUMBER_OF_OCTETS_FOR_OPTIONAL_LIST_OF_NUMBERS_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__INTERPRETATION_OF_LIST_OF_NUMBERS:
				return interpretationOfListOfNumbers != INTERPRETATION_OF_LIST_OF_NUMBERS_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE_NUMBER:
				return gridDefinitionTemplateNumber != GRID_DEFINITION_TEMPLATE_NUMBER_EDEFAULT;
			case SectionsPackage.GRID_DEFINITION_SECTION__GRID_DEFINITION_TEMPLATE:
				return gridDefinitionTemplate != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (startOffset: "); //$NON-NLS-1$
		result.append(startOffset);
		result.append(", endOffset: "); //$NON-NLS-1$
		result.append(endOffset);
		result.append(", length: "); //$NON-NLS-1$
		result.append(length);
		result.append(", sourceOfGridDefinition: "); //$NON-NLS-1$
		result.append(sourceOfGridDefinition);
		result.append(", numberOfDataPoints: "); //$NON-NLS-1$
		result.append(numberOfDataPoints);
		result.append(", numberOfOctetsForOptionalListOfNumbers: "); //$NON-NLS-1$
		result.append(numberOfOctetsForOptionalListOfNumbers);
		result.append(", interpretationOfListOfNumbers: "); //$NON-NLS-1$
		result.append(interpretationOfListOfNumbers);
		result.append(", gridDefinitionTemplateNumber: "); //$NON-NLS-1$
		result.append(gridDefinitionTemplateNumber);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.sections.GridDefinitionSection#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) throws SectionException {
		sourceOfGridDefinition = buffer.get();
		numberOfDataPoints = buffer.getInt();
		numberOfOctetsForOptionalListOfNumbers = buffer.get();
		interpretationOfListOfNumbers = buffer.get();
		gridDefinitionTemplateNumber = buffer.getShort();
		try {
			gridDefinitionTemplate = GribSecondEditionTemplatesFactory.createGribSecondEdition(GridDefinitionTemplateNumber.get(gridDefinitionTemplateNumber));
			gridDefinitionTemplate.initialise(buffer);
		} catch (GridException e) {
			throw new SectionException(e.getMessage());
		}
	}

} //GridDefinitionSectionImpl
